39 |
1Z0-816 |
Given the declaration:
@interface Resource {
String name ( ) ;
int priority ( ) default 0;
}
Examine this code fragment:
/* Loc1 */ class ProcessOrders { ... }
Which two annotations may be applied at Loc1 in the code fragment? (Choose two.) |
|
@Resource(priority=100)
|
@Resource(priority=0)
|
@Resource(name=“Customer1â€, priority=100)
|
@Resource(name=“Customer1â€)
|
@Resource |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1,2 |
|
MC |
|
|
38 |
1Z0-816 |
Given: |
38-quejav2.png |
public String toString() { return String.valueOf(ALPHA.v); }
|
public String toString() { return String.valueOf(Letter.values()[1]); }
|
public String toString() { return String.valueOf(v); }
|
String toString() { return “200â€; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
SC |
|
|
37 |
1Z0-816 |
Given: |
37-quejav2.png |
“eeee dd+”th of”+ MMM yyyy” |
“eeee dd'th of' MMM yyyy” |
“eeee d+”th of”+ MMMM yyyy” |
“eeee d’th of’ MMMM yyyy” |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
SC |
|
|
36 |
1Z0-816 |
Given : |
36-quejav2.png |
QUALITY.A.ValueOf()
|
A |
A.toString() |
QUALITY.A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
SC |
|
|
35 |
1Z0-816 |
Which interface in the java.util.function package can return a primitive type?
|
|
ToDoubleFunction |
Supplier |
BiFunction |
LongConsumer |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
SC |
|
|
34 |
1Z0-816 |
Given : |
34-quejav2.png |
Orange Juice
|
The compilation fails.
|
Orange Juice
Apple Pie
Lemmon Ice
Raspberry Tart |
The program prints nothing.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
SC |
|
|
33 |
1Z0-816 |
Which three annotation uses are valid? (Choose three.)
|
|
Function func = (@NonNull x) −> x.toUpperCase();
|
var v = “Hello†+ (@Interned) “Worldâ€
|
Function func = (var @NonNull x) −> x.toUpperCase();
|
Function func = (@NonNull var x) −> x.toUpperCase();
|
var myString = (@NonNull String) str;
|
var obj = new @Interned MyObject();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1,3,6 |
|
SC |
|
|
32 |
1Z0-816 |
A bookstore's sales are represented by a list of Sale objects populated with the name of the customer and the books they purchased. |
32-quejav2.png |
A |
B |
C |
D |
|
|
|
|
|
|
|
|
|
|
|
32-Ajav2ans.png |
32-Bjav2ans.png |
32-Cjav2ans.png |
32-Djav2ans.png |
|
|
|
|
|
|
|
|
|
|
|
3 |
|
SC |
|
|
31 |
1Z0-816 |
Given: |
31-quejav2.png |
Define the serialPersistentFields array field.
|
Declare fields transient. |
Implement only readResolve to replace the instance with a serial proxy and not writeReplace.
|
Make the class abstract.
|
Implement only writeReplace to replace the instance with a serial proxy and not readResolve.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1,3 |
|
MC |
|
|
30 |
1Z0-816 |
Which two statements set the default locale used for formatting numbers, currency, and percentages? (Choose two.)
|
|
Locale.setDefault(Locale.Category.FORMAT, “zh-CNâ€);
|
Locale.setDefault(Locale.Category.FORMAT, Locale.CANADA_FRENCH);
|
Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
|
Locale.setDefault(“en_CAâ€);
|
Locale.setDefault(“esâ€, Locale.US);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2,4 |
|
MC |
|
|
29 |
1Z0-816 |
Given the code fragment: |
29-quejav2.png |
java.lang.Runnable
|
java.util.function.Predicate
|
java.util.function.Predicate
|
java.util.concurrent.Callable |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
SC |
|
|
28 |
1Z0-816 |
Given : |
28-quejav2.png |
Move the entire Student class declaration to a separate Java file, Student.java.
|
Change line 2 to public Student(String classname).
|
Change line 1 to public class Student {.
|
Change line 3 to Student student = new Student(“Biologyâ€);.
|
Change line 1 to static class Student {.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2,4 |
|
MC |
|
|
27 |
1Z0-816 |
Given: |
27-quejav2.png |
The output will be exactly 2 1 3 4 5.
|
The program prints 1 4 2 3, but the order is unpredictable.
|
Replacing forEach() with forEachOrdered(), the program prints 2 1 3 4 5, but the order is unpredictable.
|
Replacing forEach() with forEachOrdered(), the program prints 1 2 3 4 5.
|
Replacing forEach() with forEachOrdered(), the program prints 2 1 3 4 5.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2,4 |
|
MC |
|
|
26 |
1Z0-816 |
Given: |
26-quejav2.png |
Change line 7 to return names.clone();.
|
Change line 4 to this.names = names.clone();.
|
Change the getNames() method name to get$Names().
|
Change line 6 to public synchronized String[] getNames() {.
|
Change line 2 to private final String[] names;.
|
Change line 3 to private Secret(String[] names) {.
|
Change line 2 to protected volatile String[] names;.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5,6,7 |
|
MC |
|
|
25 |
1Z0-816 |
Given: |
25-quejav2.png |
[[A, B],[A, B]]
|
An exception is thrown at run time.
|
[[A, B], [A, B, C]]
|
[[A, B, C], [A, B, C]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
SC |
|
|
24 |
1Z0-816 |
Given: |
24-quejav2.png |
before this object is deserialized
|
after this object is deserialized
|
before this object Is serialized
|
The method is never called.
|
after this object is serialized
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
SC |
|
|
23 |
1Z0-816 |
Which is a proper JDBC URL?
|
|
jdbe.mysql.com://localhost:3306/database
|
http://localhost.mysql.com:3306/database
|
http://localhost mysql.jdbc:3306/database
|
jdbc:mysql://localhost:3306/database
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
SC |
|
|
22 |
1Z0-816 |
A company has an existing sales application using a Java 8 jar file containing packages:
|
22-quejav2.png |
A |
B |
C |
D |
|
|
|
|
|
|
|
|
|
|
|
22-Ajav2ans.png |
22-Bjav2ans.png |
22-Cjav2ans.png |
22-Djav2ans.png |
|
|
|
|
|
|
|
|
|
|
|
3 |
|
SC |
|
|
21 |
1Z0-816 |
Which code is correct?
|
|
Runnable r = “Message†−> System.out.println();
|
Runnable r = () −> System.out::print;
|
Runnable r = () -> {System.out.println(“Messageâ€);}; |
Runnable r = −> System.out.println(“Messageâ€);
|
Runnable r = {System.out.println(“Messageâ€)};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
SC |
|
|
20 |
1Z0-816 |
Given: |
20-quejav2.png |
The compilation fails because there is no zero args constructor defined in class X.
|
The compilation fails because either class X or class Y needs to implement the toString() method.
|
The compilation fails because a final class cannot extend another class.
|
The compilation succeeds.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
SC |
|
|
19 |
1Z0-816 |
Given :
|
19-quejav2.png |
A NullPointerException is thrown at run time.
|
The compilation fails.
|
1
Null
null |
1
1
1 |
A ClassCastException is thrown at run time.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
SC |
|
|
18 |
1Z0-816 |
Given: |
18-quejav2.png |
Insert Comparator on line 1.
Insert
public int compare(Person p1, Person p2) {
return p1.name.compare(p2.name);
}
on line 2 |
Insert Comparator on line 1.
Insert
public int compareTo(Person person) {
return person.name.compareTo(this.name);
}
on line 2. |
Insert Comparable on line 1.
Insert
public int compare(Person p1, Person p2) {
return p1.name.compare(p2.name);
}
on line 2 |
Insert Comparator on line 1.
Insert
public int compare(Person person) {
return person.name.compare(this.name);
}
on line 2. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
SC |
|
|
17 |
1Z0-816 |
Given : |
17-quejav2.png |
The compilation fails.
|
/u01/work/filestore.txt is not deleted.
|
Exception |
/u01/work/filestore.txt is deleted.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
SC |
|
|
16 |
1Z0-816 |
Given: |
16-quejav2.png |
@AuthorInfo (date="1-12020", comments={ null } )
public class Hello {
public void func( ) { }
} |
public class Hello {
@AuthorInfo (date="1-1-2020. comments="Hello");
public void func ( ) { }
} |
public class Hello {
@Author Info
public void func ( ) { }
} |
@AuthorInfo (date="1-1-2020")
public class Hello {
public void func ( ) { }
} |
public class Hello {
@AuthorInfo (date="1-1-2020", author+"Gandhi", comments={ "word" }}
public void func ( ) { }
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3,4 |
|
MC |
|
|
15 |
1Z0-816 |
Given : |
15-quejav2.png |
double totalSalary = list.stream().map(e −> e.getSalary() * ratio).reduce(bo).ifPresent (p −> p.doubleValue());
|
double totalSalary = list.stream().mapToDouble(e −> e.getSalary() * ratio).sum;
|
double totalSalary = list.stream().map(Employee::getSalary * ratio).reduce(bo).orElse(0.0);
|
double totalSalary = list.stream().mapToDouble(e −> e.getSalary() * ratio).reduce(starts, bo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
SC |
|
|
14 |
1Z0-816 |
Given: |
14-quejav2.png |
System.out is the standard output stream. The stream is open only when System.out is called.
|
System.in cannot reassign the other stream.
|
System.out is an instance of java.io.OutputStream by default.
|
System.in is the standard input stream. The stream is already open.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
SC |
|
|
13 |
1Z0-816 |
Given: |
13-quejav2.png |
Function function = String::toUpperCase;
|
UnaryOperator function = s −> s.toUpperCase();
|
UnaryOperator function = String::toUpperCase;
|
Function function = m −> m.toUpperCase();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
SC |
|
|
12 |
1Z0-816 |
var numbers = List.of(0,1,2,3,4,5,6,7,8,9);
You want to calculate the average of numbers.
Which two codes will accomplish this? (Choose two.) |
|
double avg = numbers.stream().parallel().averagingDouble(a −> a);
|
double avg = numbers.parallelStream().mapToInt (m −> m).average().getAsDouble();
|
double avg = numbers.stream().mapToInt (i −> i).average().parallel();
|
double avg = numbers.stream().average().getAsDouble();
|
double avg = numbers.stream().collect(Collectors.averagingDouble(n −> n));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2,4 |
|
MC |
|
|
11 |
1Z0-816 |
Given: |
11-quejav2.png |
Replace public Color(int c) with private Color(int c).
|
Replace int c; with private int c;.
|
Replace int c; with private final int c;.
|
Replace enum Color implements Serializable with public enum Color.
|
Replace enum Color with public enum Color.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
SC |
|
|
10 |
1Z0-816 |
Given: |
10-quejav2.png |
Hello.Greeting myG = new Hello.Greeting()
myG.sayHi();
|
Hello myH = new Hello();
Hello.Greeting myG = myH.new Greeting();
myG.sayHi(); |
Hello myH = new Hello();
Hello.Greeting myG = myH.new Hello.Greeting();
myG.sayHi(); |
Hello myH = new Hello();
Greeting myG = new Greeting();
myG.sayHi (); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
SC |
|
|
9 |
1Z0-816 |
Which two are successful examples of autoboxing? (Choose two.) |
|
String a = “Aâ€;
|
Integer e = 5;
|
Float g = Float.valueOf(null);
|
Double d = 4;
|
Long c = 23L;
|
Float f = 6.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1,2 |
|
MC |
|
|
8 |
1Z0-816 |
Given : |
08-quejav2.png |
[Market Road, 1000]
|
[Peter, 30, Market Road]
|
[Peter, 25, null, 1000]
|
An exception is thrown at run time.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
SC |
|
|
7 |
1Z0-816 |
Given : |
07-quejav2.png |
change is required.
|
Make the declaration of lock static.
|
Replace the lock constructor call with new ReentrantLock (true).
|
Move the declaration of lock inside the foo method.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
SC |
|
|
6 |
1Z0-816 |
Assuming the Widget class has a getPrice method, this code does not compile:
|
06-quejav2.png |
Replace line 5 with widgetStream.filter(a −> ((Widget)a).getPrice() > 20.00).
|
Replace line 1 with List widgetStream = widgets.stream();. |
Replace line 5 with widgetStream.filter((Widget a) −> a.getPrice() > 20.00).
|
Replace line 4 with Stream widgetStream = widgets.stream();.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1,4 |
|
MC |
|
|
5 |
1Z0-816 |
Assume ds is a DataSource and the EMP table is defined appropriately. |
05-quejav2.png |
inserts two rows (101, 'SMITH', 'HR') and (102, 'JONES', NULL) |
inserts two rows (101, 'SMITH', 'HR') and (102, 'JONES', 'HR') |
inserts one row (101, 'SMITH', 'HR') |
throws a SQLException |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
SC |
|
|
4 |
1Z0-816 |
Given: |
04-quejav2.png |
null |
A NoSuchElementException is thrown at run time.
|
Duke |
NullPointerException is thrown at run time.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
SC |
|
|
3 |
1Z0-816 |
Given: |
03-quejav2.png |
An IllegalThreadStateException is thrown at run time.
|
Three threads are created.
|
The compilation fails.
|
Four threads are created.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
SC |
|
|
2 |
1Z0-816 |
Given: |
02-quejav2.png |
private default void probeProcedure ( ) {
System.out.println("Launch probe") ;
System.out.println("Land on Asteroid");
}
|
static void probeProcedure ( ) {
System.out.println("Launch probe");
System.out.println("Land on Asteriod");
} |
private void probeProcedure ( ) {
System.out.println("Launch probe");
System.out.println("Land on Asteriod");
} |
default void probe Procedure ( ) {
System.out.println("Launch probe");
System.out.println("Land on Asteriod");
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
SC |
|
|
1 |
1Z0-816 |
Given the declaration: |
01-quejav2.png |
@Resource(priority=100)
|
@Resource(priority=0)
|
@Resource(name=“Customer1â€, priority=100)
|
@Resource(name=“Customer1â€)
|
@Resource
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1,2 |
|
MC |
|
|